<template>
    <example :template-code="templateString">
        <template #describe>
            <t :id="`${$t('日期选择(单选)')}`">{{ $t('日期选择(单选)') }}</t>
            <li>
                配置<span class="d-code">shortcuts</span>可以设置快捷选项；
            </li>
        </template>
        <div style="display:flex;color:#999;">
            <div style="width: 300px;margin-right:20px;">
                <p style="color:#666;">普通用法：</p>
                <sib-item v-model="value1" :props="props1"></sib-item>
                <p>当前选择的是：{{ value1 }}</p>
            </div>
            <div style="width: 300px;margin-right:20px;">
                <p style="color:#666;">设置快捷选项：</p>
                <sib-item v-model="value2" :props="props2"></sib-item>
                <p>当前选择的是：{{ value2 }}</p>
            </div>
        </div>
    </example>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value1 = ref(null);
        const value2 = ref(null);
        const props1 = reactive({
            type: 'date',
        });
        const props2 = reactive({
            type: 'date',
            shortcuts: [
                {
                    text: '彼时彼刻',
                    value: () => new Date('1995-03-10'),
                },
                {
                    text: '此时此刻',
                    value: new Date(),
                },
            ],
        });

        return {
            value1,
            value2,
            props1,
            props2,
            templateString: `<template>
    <div style="display:flex;">
        <div style="width: 300px;">
            <p>普通用法：</p>
            <sib-item v-model="value1" :props="props1"></sib-item>
            <p>当前选择的是：{{ value1 }}</p>
        </div>
        <div style="width: 300px;">
            <p>设置快捷选项：</p>
            <sib-item v-model="value2" :props="props2"></sib-item>
            <p>当前选择的是：{{ value2 }}</p>
        </div>
    </div>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value1 = ref(null);
        const value2 = ref(null);
        const props1 = reactive({
            type: 'date',
        });
        const props2 = reactive({
            type: 'date',
            shortcuts: [
                {
                    text: '彼时彼刻',
                    value: () => new Date('1995-03-10'),
                },
                {
                    text: '此时此刻',
                    value: new Date(),
                },
            ],
        });

        return { value1, value2, props1, props2 };
    },
};
<\/script>`,
        };
    },
};
</script>
